package com.wbao.dianniu.update;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by yejianjun on 2018/7/12.
 */

public class FriendListHelper {

    private static FriendListHelper instance;
    private static List<IFriendChangeListener> mListener = null;

    public static FriendListHelper getInstance() {
        if (null == instance) {
            instance = new FriendListHelper();
            mListener = new ArrayList<>();
        }
        return instance;
    }

    public interface IFriendChangeListener {
        public void deleteFriend(int friendid);

        public void cancelFollow(int followId);
    }

    public FriendListHelper() {

    }

    public void addListener(IFriendChangeListener listenr) {
        if (null == mListener) {
            mListener = new ArrayList<>();
        }
        mListener.add(listenr);
    }

    public void removeListener(IFriendChangeListener listener) {
        if (null != mListener) {
            mListener.remove(listener);
        }
    }

    public void deleteFriend(int friendId) {
        if (null != mListener) {
            for (int i = 0; i < mListener.size(); i++) {
                mListener.get(i).deleteFriend(friendId);
            }
        }
    }

    public void cancelFollow(int friendId) {
        if (null != mListener) {
            for (int i = 0; i < mListener.size(); i++) {
                mListener.get(i).cancelFollow(friendId);
            }
        }
    }


}
